import { filePost, post } from '../../http'
import store from '@/store'

// 获取上半部分列表数据
export const queryBiddingList = ({
  bidCode,
  bidId,
  bidAuditstatus,
  bidBiddingstatus,
  bidInternalStatus,
  enrollStatus,
  biddingStatus,
  bidPlatformTogether,
  biddingEnd,
  monitorStatus,
  reviewStatus,
  bidName,
  PageIndexs,
  PageSizes,
  biddingStartTime,
  biddingEndTime,
  bidStatus
}) =>
  post('/FTKJWLHYPT/bidding/queryBiddingList', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidCode,
          bidId,
          bidName,
          bidAuditstatus,
          bidBiddingstatus,
          bidInternalStatus,
          bidPlatformTogether,
          enrollStatus,
          biddingStatus,
          reviewStatus,
          biddingEnd,
          monitorStatus,
          biddingStartTime,
          biddingEndTime,
          bidStatus,
          userId: store.state.user.UserId_DX_H,
          fltId: store.state.user.FLT_UUID_DX_H,
          dptId: store.state.user.DPTID_DX_H,
          userName: store.state.user.USERNAME_DX_H
        }
      },
      Orderbys: {},
      PageIndex: {
        FTKJWLHYPT: PageIndexs
      },
      PageSize: {
        FTKJWLHYPT: PageSizes
      }
    }
  })

export const getNoPayBiddingsByGYS = ({}) =>
  post('/FTKJWLHYPT/bidding/getNoPayBiddingsByGYS', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltId: store.state.user.FLT_UUID_DX_H
        }
      },
    }
  })

//审核
export const auditBiddingMethod = ({ bidId, bidAuditstatus, bidAuditOpinion, bidStatus }) => {
  return post('/FTKJWLHYPT/bidding/auditBiddingMethod', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId,
          bidAuditstatus,
          bidAuditOpinion,
          bidStatus,
          bidEditor: store.state.user.USR_CODE_DX_H
          // fltUuid: store.state.user.FLT_UUID_DX_H,
        }
      }
    }
  })
}

//审核页面驳回需求更改运输数量
export const overRuleBiddingMethod = ({ bidId, bidAmount }) => {
  return post('/FTKJWLHYPT/bidding/overRuleBidding', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId,
          bidAmount,
          bidEditor: store.state.user.USR_CODE_DX_H
        }
      }
    }
  })
}

//审核页面更改需求运输量同步标书运输量
export const editBiddingQuantityMethod = ({ bidId }) => {
  return post('/FTKJWLHYPT/bidding/editBiddingQuantity', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId
        }
      }
    }
  })
}

//评审
export const reviewBiddingMethod = ({ bidId, sugarId, reviewStatus }) => {
  return post('/FTKJWLHYPT/bidding/reviewBiddingMethod', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId,
          sugarId,
          reviewStatus,
          editor: store.state.user.USR_CODE_DX_H,
          dptId: store.state.user.DPTID_DX_H
        }
      }
    }
  })
}

// 获取当前登录供应商可查看的已发布的标书信息
export const queryBiddingStatusList = ({ bidName, bidCode, bidAuditstatus, bidBiddingstatus, enrollStatus, biddingStatus, PageIndexs, PageSizes }) =>
  post('/FTKJWLHYPT/bidding/queryBiddingStatusList', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidName,
          bidCode,
          bidAuditstatus,
          bidBiddingstatus,
          enrollStatus,
          biddingStatus,
          userId: store.state.user.UserId_DX_H,
          fltId: store.state.user.FLT_UUID_DX_H,
          dptId: store.state.user.DPTID_DX_H,
          userName: store.state.user.USERNAME_DX_H
        }
      },
      Orderbys: {},
      PageIndex: {
        FTKJWLHYPT: PageIndexs
      },
      PageSize: {
        FTKJWLHYPT: PageSizes
      }
    }
  })
//查询已报名供应商和竞价状态--竞价结果审核
export const queryBiddingInfoList = ({ bidId, sugarId, biddingEnd, reviewStatus, quotaStatus, biddingStatus, status }) => {
  return post('/FTKJWLHYPT/bidding/queryBiddingInfoList', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId,
          sugarId,
          biddingEnd,
          reviewStatus,
          quotaStatus,
          biddingStatus,
          status,
          userId: store.state.user.UserIdc_DX_H,
          creator: store.state.user.USERNAME_DX_H,
          fltId: store.state.user.FLT_UUID_DX_H,
          dptId: store.state.user.DPTID_DX_H
        }
      }
    }
  })
}

//查询供应商配额的需求信息
export const quotaBiddingMethod = data => {
  return post('/FTKJWLHYPT/bidding/quotaBiddingMethod', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId: data.bidId,
          reviewStatus: data.reviewStatus
        }
      }
    }
  })
}

//确定配额
export const biddingQuotaMethod = BiddingPriceInfo => {
  return post('/FTKJWLHYPT/bidding/biddingQuotaMethod', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          BiddingPriceInfo,
          editor: store.state.user.USERNAME_DX_H
        }
      }
    }
  })
}

//取消配额
export const delBiddingQuotaMethod = data => {
  return post('/FTKJWLHYPT/bidding/delBiddingQuotaMethod', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bqFltId: data.bqFltId,
          bqFltName: data.bqFltName,
          quotaStatus: data.quotaStatus,
          bqBidId: data.bqBidId,
          bqTransportQuantity: data.bqTransportQuantity,
          bqSugarId: data.bqSugarId,
          bqBiddingId: data.bqBiddingId,
          bqBiddingPrice: data.bqBiddingPrice,
          bqId: data.bqId,
          editor: store.state.user.USERNAME_DX_H
        }
      }
    }
  })
}

//查询数据库服务器当前时间
export const queryNowTime = () => {
  return post('/FTKJWLHYPT/bidding/queryNowTime', {})
}

//查询供应商配额的需求信息
export const querytSignUpSugar = data => {
  return post('/FTKJWLHYPT/bidAdminister/querytSignUpSugar', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId: data.bidId,
          sugarId: data.sugarId,
          signupStatus: data.signupStatus,
          fltId: store.state.user.FLT_UUID_DX_H
        }
      }
    }
  })
}

//暂停竞价和取消暂停
export const stopBiddingStatus = data => {
  return post('/FTKJWLHYPT/bidAdminister/stopBidding', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId: data.bidId,
          box: data.box,
          bidBiddingEnd: data.bidBiddingEnd,
          bidStopStatus: data.bidStopStatus,
          bidStopMan: store.state.user.USERNAME_DX_H
        }
      }
    }
  })
}

export const exportBiddingResult = ({ bidId, demandIds, biddingEnd, biddingStatus }) =>
  filePost('/FTKJWLHYPT/bidAdminister/exportResult', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          bidId: bidId,
          demandIds: demandIds,
          biddingEnd,
          biddingStatus
        }
      }
    }
  })
